package cn.com.shopec.erp.stock.excel.impl;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;

import cn.com.shopec.erp.common.excel.ExcelBaseExport;
import cn.com.shopec.erp.stock.vo.StockInVo;

public class StockInExcelExport extends ExcelBaseExport {

	public StockInExcelExport(List<StockInVo> data, String fileName,
			HttpServletResponse response) {
		super(data, fileName, response);
	}

	@Override
	protected Row setColumnMapping(Object data, Row row) {
		StockInVo stockInVo = (StockInVo) data;
		int cellIndex = 0;
		Cell cell = row.createCell(cellIndex++);
		cell.setCellValue(stockInVo.getStockInNo());

		cell = row.createCell(cellIndex++);
		cell.setCellValue(stockInVo.getPurNo());

		cell = row.createCell(cellIndex++);
		cell.setCellValue(getStockInTypeName(stockInVo.getStockInType()));

		cell = row.createCell(cellIndex++);
		cell.setCellValue(stockInVo.getSupName());

		cell = row.createCell(cellIndex++);
		cell.setCellValue(stockInVo.getWhName());

		cell = row.createCell(cellIndex++);
		cell.setCellValue(stockInVo.getCreateTime());
		
		cell = row.createCell(cellIndex++);
		cell.setCellValue(stockInVo.getUpdateTime());
		
		cell = row.createCell(cellIndex++);
		cell.setCellValue(stockInVo.getUpdater());
		
		cell = row.createCell(cellIndex++);
		cell.setCellValue(stockInVo.getStockInState()==1?"已入库":"未入库");
		
		return row;
	}

	@Override
	protected List<String> setExcelTitleValue() {
		List<String> title = new ArrayList<String>();
		title.add("入库单号");
		title.add("采购单号");
		title.add("入库类型");
		title.add("供应商名称");
		title.add("仓库");
		title.add("创建时间");
		title.add("入库时间");
		title.add("入库员");
		title.add("入库状态");
		return title;
	}
	
	private String getStockInTypeName(int type){
		String typename = "";
        switch(type){
            case 1: typename="货品采购入库"; break;
            case 2: typename="订单退换货入库"; break; 
            case 3: typename="次品退换货入库"; break;
            case 4: typename="采购退换货入库"; break;
            case 5: typename="调拨入库 "; break; 
            case 6: typename="其他入库"; break;
            default : break; 
        }
        return typename; 
	}

}
